package com.zrrd.learn.framework.mvc.controller;

import com.alibaba.fastjson2.JSON;
import com.zrrd.learn.framework.mvc.service.DemoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wrn
 * @version 1.0
 * @date 2023/9/18 11:00
 */
@RestController
public class DemoController {

    @Resource
    DemoService demoService;

    /**
     * 写一个代码把java转换成为json
     *
     *  {name=kjx}
     *  {"name":"kjx"}
     *
     *  1 :  手写
     *  2 :  json转换包
     *  2.1 alibaba fastjson2
     *
     *
     * @return
     */
    @GetMapping("/hello")
    public String showall(){
        List<Integer> list = demoService.showall();
        return JSON.toJSONString(list);
    }

    @GetMapping("/h1")
    public String abc(){
        return "hello world";
    }

}
